<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "sku".
 *
 * @property int $id
 * @property int $product_id 产品id
 * @property string $attr_data sku
 * @property float $price 价格
 * @property int $stock_num 库存量
 * @property int $sale_num 销量
 */
class Sku extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'sku';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['product_id', 'attr_data', 'price', 'stock_num'], 'required'],
            [['product_id', 'stock_num'], 'integer'],
            [['attr_data'], 'safe'],
            ['sale_num', 'default', 'value' => 0],
            [['price'], 'number'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'product_id' => Yii::t('app', 'Product ID'),
            'attr_data' => Yii::t('app', 'Attr Data'),
            'price' => Yii::t('app', 'Price'),
            'stock_num' => Yii::t('app', 'Stock Num'),
            'sale_num' => Yii::t('app', 'Sale Num'),
        ];
    }
}
